home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_sniffer.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  951 b   |  48 lines

  1. /*
  2.   decode_sniffer.c
  3.  
  4.   Network Associates Sniffer.
  5.   
  6.   Copyright (c) 2000 Anonymous <nobody@localhost>
  7.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  8.  
  9.   $Id: decode_sniffer.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  10. */
  11.  
  12. #include <sys/types.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include "base64.h"
  16. #include "decode.h"
  17.  
  18. int 
  19. decode_sniffer(u_char *buf, int len)
  20. {
  21.     u_int i, opcode;
  22.     
  23.     if (len < 36 || buf[0] != 5)
  24.         return (0);
  25.     
  26.     opcode = pletohs(&buf[6]);
  27.     
  28.     if (opcode == 260) {
  29.         if (buf[32] == 0)
  30.             return (strlcpy(Buf, "[]\n", sizeof(Buf)));
  31.     }
  32.     else if (opcode == 261) {
  33.         if (pletohl(&buf[32]) == -1)
  34.             return (strlcpy(Buf, "[]\n", sizeof(Buf)));
  35.     }
  36.     else return (0);
  37.     
  38.     buf[len - 3]= '\0'; strtok(&buf[32], "\r\n");
  39.     snprintf(Buf, sizeof(Buf), "%s [", &buf[32]);
  40.     len = strlen(Buf);
  41.     i = base64_pton(&buf[32], &Buf[len], sizeof(Buf) - len - 3);
  42.     Buf[len + i] = '\0';
  43.     strlcat(Buf, "]\n", sizeof(Buf));
  44.     
  45.     return (strlen(Buf));
  46. }
  47.  
  48.